package io.jsen.meta.diff.obj.special;

import io.jsen.meta.diff.field.MetaField;
import io.jsen.meta.diff.obj.MetaObject;
import lombok.EqualsAndHashCode;

import static io.jsen.meta.diff.support.MetaChangeModifier.setDelete;
import static io.jsen.meta.diff.support.MetaChangeModifier.setNoChange;

/**
 * 代表空字段
 *
 * @author jsen
 * @date 2021/4/6
 */
@EqualsAndHashCode(callSuper = true)
public class MetaNull extends MetaObject<MetaNull, MetaNull.Null> {
    private static final Null NULL = new Null();

    public MetaNull(MetaField metaField) {
        super(metaField, NULL);
    }

    @Override
    protected int calState(MetaNull obj) {
        if (isDelVal()) {
            return setDelete(0);
        }
        return setNoChange(0);
    }

    @Override
    public String createIndex() {
        return NULL.toString();
    }

    public static final class Null {
        @Override
        public String toString() {
            return "NULL VALUE";
        }
    }
}
